package com.jd.jobkeeper.transport;

import com.jd.jobkeeper.utils.InvokerHandler;

import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;

public class HandlerRegistry {

    private Map<String, InvokerHandler> handlerMap = new HashMap<>();

    public void register(Object proxy, Class<?> interfaceType) {
        for (Method method : interfaceType.getDeclaredMethods()) {
            handlerMap.put(method.getName(), new InvokerHandler(proxy, method));
        }
    }

    public InvokerHandler lookup(String route){
        return handlerMap.get(route);
    }
}
